package com.yhp.bean.dto;

import java.util.ArrayList;
import java.util.List;

import com.yhp.bean.Menu;
import com.yhp.bean.Role;

/**
 * Menu DTO
 *
 * @author bing.zhang06@hand-china.com 2021/7/31 16:39
 **/
public class MenuDTO {
    private Integer menuId;
    private String menuName;
    private Integer upmenuId;
    private Integer state;
    // 是否选中
    private Boolean checked;
    private String desc;
    private String url;
    private List<Role> roleList;
    //保存二级目录
    private List<MenuDTO> secondMenuList;

    public MenuDTO() {
    }

    public MenuDTO(Menu menu) {
        copyProperties(this, menu);
        // 处理二级菜单
        List<Menu> secondMenuList = menu.getSecondMenuList();
        List<MenuDTO> menuDTOS = new ArrayList<>();
        for (Menu var : secondMenuList) {
            MenuDTO menuDTO = new MenuDTO();
            copyProperties(menuDTO, var);
            menuDTOS.add(menuDTO);
        }
        this.secondMenuList = menuDTOS;
    }

    private void copyProperties(MenuDTO var1, Menu var2) {
        var1.menuId = var2.getMenuId();
        var1.menuName = var2.getMenuName();
        var1.upmenuId = var2.getUpmenuId();
        var1.state = var2.getState();
        var1.desc = var2.getDesc();
        var1.url = var2.getUrl();
        var1.roleList = var2.getRoleList();
    }

    public List<MenuDTO> getSecondMenuList() {
        return secondMenuList;
    }

    public void setSecondMenuList(List<MenuDTO> secondMenuList) {
        this.secondMenuList = secondMenuList;
    }

    public Boolean getChecked() {
        return checked;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    public Integer getMenuId() {
        return menuId;
    }

    public void setMenuId(Integer menuId) {
        this.menuId = menuId;
    }

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public Integer getUpmenuId() {
        return upmenuId;
    }

    public void setUpmenuId(Integer upmenuId) {
        this.upmenuId = upmenuId;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }
}
